﻿@rendermode InteractiveServer

@inherits AuthComponentTabLeftBase<ApplicationViewModel,string,ApplicationEditModal>

@if (pageData == null)
{
	<Spin size="SpinSize.Large" Tip="Loading..." />
}
else
{
	<Table @ref="table" Class="@tableHeightCssName" ScrollX="@tableScrollX" AutoColIndexes="false"
		   TItem="ApplicationViewModel" DataSource="@pageData.Items"
		   OnExpand="OnRowExpand" OnRowClick="OnRowClick"
		   RowKey="x=>x.Id" Size="TableSize.Small"
		   Loading="tableLoading"
		   @bind-SelectedRows="@selectedRows"
		   AutoHeight Resizable Bordered EnableVirtualization
		   PageSize="PageSize">

		<TitleTemplate>

			<GridRow Wrap="false">
				<GridCol Flex=@("none")>
					<Space>
						<SpaceItem>
							<Search Placeholder="名称(left)" @bind-Value="searchModel.DisplayName" OnSearch="async () => { await OnSearch(pageargs); ShowMessage(); }" AllowClear="true" />
						</SpaceItem>

						<SpaceItem>
							<Button Type="@ButtonType.Primary" Icon="@IconType.Outline.Reload" OnClick="() => ReSet()">重置</Button>
						</SpaceItem>

					</Space>
				</GridCol>
				<GridCol Flex=@("auto")>
					<Flex Justify="FlexJustify.End">
						<Tooltip Title="表格功能设置">
							<Button Type="ButtonType.Link" Shape="ButtonShape.Circle" Icon="@IconType.Outline.Setting" Size="ButtonSize.Large" Style="color:grey;" OnClick="onClickTableSet"></Button>
						</Tooltip>
					</Flex>
				</GridCol>
			</GridRow>
		</TitleTemplate>

		<ColumnDefinitions>
			<Selection Type="@selectionType" Width="50"></Selection>
			<GenerateColumns Range="1.." HideColumnsByName="ColumnsByNamesHide" Definitions=DefinitionColumns />

			@*<ActionColumn Title="Action" Fixed="ColumnFixPlacement.Right" Width="100">
				<Space>
					<SpaceItem>
						<Tooltip Title="@IconType.Outline.Edit">
							<Button OnClick="(e) => MainEditModal.MeCrud.ShowEdit(context)" Shape="@ButtonShape.Circle" Icon="@IconType.Outline.Edit" />
						</Tooltip>
					</SpaceItem>
					<SpaceItem>
						<Popconfirm Title="确认删除?"
									OnConfirm="(e) => MainEditModal.DeleteData(context)"
									OkText="Yes"
									CancelText="No">
							<Button Icon="@IconType.Outline.Delete" Shape="@ButtonShape.Circle" Danger></Button>
						</Popconfirm>
					</SpaceItem>
				</Space>
			</ActionColumn> *@
		</ColumnDefinitions>


		<PaginationTemplate>
			<Pagination ShowTotal="baseRender.showTotal" Class="@(context.PaginationClass + " my-custom-pagination")"
						Total="pageData.Total"
						Current="pageData.Page"
						PageSize="PageSize"
						PageSizeOptions="PageSizeOptions"
						ShowSizeChanger
						ShowQuickJumper
						OnChange="OnSearch" />
		</PaginationTemplate>
	</Table>

	<Modal Title="@modal.Title" Class="@modal.Class" MaxBodyHeight="@modal.MaxBodyHeight"
		   Resizable Maximizable ResizedChanged=@modal.ResizedChanged
		   Width="@modal.Width" BodyStyle="@modal.Style"
		   @bind-Visible="@modal.Visible" Draggable="@modal.Draggable" Centered=@modal.Centered
		   MaskClosable=false Closable=@modal.Closable
		   OnOk="@modal.HandleOk" OnCancel="@modal.HandleClose"
		   ConfirmLoading="modal.Loading" OkText="modal.OkTitle" CancelText="modal.CancelText">

		@modal.ModalTemplate
	</Modal>
}
<style>

	@("." + tableHeightCssName) {
		min-height: @(tableHeight + PaginationHeight + "px");
		margin: 0;
	}

		@("." + tableHeightCssName) table {
			/* min-height: @(tableHeight - ScrollBarHeight + "px");
			*/ margin: 0;
		}

		@("." + tableHeightCssName) .ant-table-content {
			/* min-height: @(tableHeight + "px");
			*/ margin-right: 5px;
		}
</style>
@code {

}
